home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* FaxOnDemand.ppak Copyright 1994 Atlantis Design Group, Inc. */
- /* */
- /* This ARexx script for PhonePak implements a one-call fax on demand */
- /* system. To use this script, create a mailbox that you can get to */
- /* via normal system routing. Put a greeting in the mailbox that */
- /* informs callers that they must be calling from a fax machine and */
- /* tells them how many faxes they can request. You might then */
- /* identify some of the more often-requested faxes, including a fax */
- /* which contains a description and an ID number for all available */
- /* faxes. You should then prompt the caller to enter the number of */
- /* the first fax they want to receive. All of the available faxes */
- /* should be placed in the mailbox, and the filename of each fax */
- /* should correspond to the number the caller enters to retrieve it. */
- /* Finally, you should set up the ARexx Route Host for the mailbox as */
- /* "FAXONDEMAND", and run this script as part of your normal system */
- /* startup procedure. This script will take over the call when the */
- /* caller makes his/her first selection. The MAXFAXES variable below */
- /* can be adjusted to limit the number of faxes that can be retrieved */
- /* in a single session. This script is set up for single line use. */
- /* The filenote of each fax will be used to keep track of the number */
- /* of times that fax has been successfully transmitted. */
- /************************************************************************/
-
- /************************************************************************/
- /* Messages needed by this script; put them in fax mailbox, too: */
- /* */
- /* YouHaveEntered.sys - "You Have Entered..." */
- /* IfCorrect.sys - "If this is correct, press 1." */
- /* Invalid.sys - "I'm sorry, you have made an invalid selection." */
- /* NextDocument.sys - "Please enter the number of the next document */
- /* you wish to receive, or if you are ready to receive the */
- /* information you have requested, press star." */
- /************************************************************************/
-
- MAXFAXES = 3
- PortName = "FAXONDEMAND" /* No line number appended */
-
- options results
- call addlib('rexxsupport.library',0,-30,0)
- call openport(PortName)
-
- address LINEMAN.1 /* We're going to talk to line 1 */
-
- /************************************************************************/
- /* MAIN LOOP */
- /************************************************************************/
- do forever
- call waitpkt(PortName)
- Pkt = getpkt(PortName)
- if Pkt = null() then
- iterate
-
- Arg = getarg(Pkt,0)
- parse var Arg . Line Mailbox Code
-
- Code = strip(Code) /* get rid of leading/trailing spaces */
- SETMAILBOX Mailbox /* Get mailbox info */
- Path = strip(word(result,1),,"'")
- call pragma('d',Path) /* CD this script to mb directory to */
- /* make it easy to verify caller's selections */
-
- 'INQUIRE HANGUP' /* Initialize hangup flag */
- QueuedFaxes = 0
- Status = DoFaxOnDemand(Code)
-
- if Status = OK & QueuedFaxes > 0 then do
- /* Build Operator string to transmit faxes and send them */
- String = ''
- do n = 0 to QueuedFaxes-1
- String = String || '<X ' || Fax.n || '>'
- end
-
- 'OPERATOR <P SYSMSG:FaxHelp.sys>' String
-
- if rc = 0 then do
- do n = 0 to QueuedFaxes-1
- FileString = statef(Fax.n)
- Note = word(FileString,8)
- if ~datatype(Note,'n') then
- Note = 0
- Note = Note + 1
- address command FileNote Fax.n Note
- end
- end
- end
-
- call reply(Pkt,1) /* Hand control back to LineMan */
- end
-
- DoFaxOnDemand: procedure expose MaxFaxes QueuedFaxes Fax.
- /************************************************************************/
- /* Purpose: */
- /* Process caller's fax selections */
- /* Arguments: */
- /* Code - Number of the first fax requested by caller */
- /* Return value: */
- /* OK - Try to transmit */
- /* END - End the call */
- /* Comments: */
- /************************************************************************/
- Code = arg(1)
- do forever
- do forever
- 'OPERATOR <P YouHaveEntered.sys>'
- call Delay(25)
- do i=1
- Num = substr(Code,i,1)
- if(Num = '') then
- leave
- 'SPEAK NUMBER' Num
- end
- call Delay(50)
- 'INQUIRE HANGUP'
- if rc = 1 then
- return END
- Entry = PlayMessage('IfCorrect.sys',1,2)
- if Entry = -1 then
- return END
- else if Entry = 1 then do
- Duplicate = FALSE
- do n = 0 to QueuedFaxes-1
- if Code = Fax.n then do
- Duplicate = TRUE
- leave;
- end
- end
- if Exists(Code) & Duplicate = FALSE then do
- Fax.QueuedFaxes = Code
- QueuedFaxes = QueuedFaxes + 1
- end
- else do
- 'OPERATOR <P Invalid.sys>'
- call Delay(50)
- end
- leave
- end
- else do
- 'OPERATOR <P Invalid.sys>'
- call Delay(50)
- leave
- end
- end
-
- if QueuedFaxes = MaxFaxes then
- return OK
-
- Code = PlayMessage('NextDocument.sys',2,3)
- if Code = '*' | Code = '' then
- return OK
- else if Code = -1 then
- return END
- end
-
- return
-
- PlayMessage: procedure
- /************************************************************************/
- /* Purpose: */
- /* To play a sound file and perform basic error handling. */
- /* Arguments: */
- /* Filename, Interdigit, Timeout */
- /* Return value: */
- /* Caller's DTMF entry */
- /* Comments: */
- /************************************************************************/
-
- do forever
- 'PLAYBACK "' || arg(1) || '"' arg(2) arg(3)
- select
- when rc = 0 then do
- if result = 'RESULT' then
- return ""
- else
- return result
- end
- when rc = 5 then /* Pound entered, repeat message */
- iterate
- when rc = 4 then /* Star entered */
- return '*'
- otherwise /* Terminate call */
- return -1
- end
- end
-